package Controllers;
import javax.swing.JOptionPane;
import Exceptions.DaoException;

import DB.javaconnect;
import com.mysql.jdbc.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class ChangePersonalData_Controller {
    
   public ChangePersonalData_Controller() {
    
}
    public void ChangePersonalData(String Name,String Surname,String Email,String Phone,String Pass,String Username, String OldUsername)
            throws ClassNotFoundException, SQLException
    {
           Connection conn=null;
           conn=javaconnect.ConnecrDb("com.mysql.jdbc.Driver","jdbc:mysql://localhost:3306/nlr");
           if(Name.isEmpty() || Surname.isEmpty() || Email.isEmpty() || Phone.isEmpty() || Pass.isEmpty() || Username.isEmpty())
                {
                    JOptionPane.showMessageDialog(null, "Empty Field");
                }
           else 
                {
                    //sql="UPDATE user SET `name`="+Name+",surname=[value-3],`username`=[value-4],`pass`=[value-5],`email`=[value-6],`phone`=[value-7],`noshop`=[value-8] WHERE 1"
                    String sql;
                    System.out.println(OldUsername);
                    sql="UPDATE user SET name='"+Name+"',surname='"+Surname+"',username='"+Username+"',pass='"+Pass+"',email='"+Email+"',phone='"+Phone+"' WHERE ID=1";
                    Statement stmt;
                    stmt= (Statement) conn.createStatement();
                    stmt.executeUpdate(sql);
                }
    }
}
